/*
 * @FilePath: \undefinedc:\Users\sxjct\.leetcode\77.组合.cpp
 * @Brief: 
 * @Version: 1.0
 * @Date: 2021-03-22 14:49:21
 * @Author: tianyiyi
 * @Copyright: Copyright@tianyiyi
 * @LastEditors: Mr.Tian
 * @LastEditTime: 2021-03-22 14:55:34
 */
/*
 * @lc app=leetcode.cn id=77 lang=cpp
 *
 * [77] 组合
 */

// @lc code=start
class Solution {
private:
    vector<vector<int>> res;
public:
    vector<vector<int>> combine(int n, int k) {
        vector<int> path;
        trackback(path , 1 , n , k);
        return res;
    }
    
    void trackback(vector<int> &path, int start ,int n, int k)
    {
        if(path.size() == k)
            res.push_back(path);
        
        for(int i = start; i <= n;i++)
        {
            path.push_back(i);
            trackback(path , i + 1 , n , k );
            path.pop_back();
        }
    }
};
// @lc code=end

